/**
 * 
 */
package com.gpms.service.systemInit;

import java.util.List;

import com.gpms.bean.SchoolTimePoint;
import com.gpms.bean.TeacherTimePoint;
import com.gpms.bean.TimePoint;
import com.gpms.bean.Topics;
import com.gpms.dao.HibernateDaoFactory;
import com.gpms.dao.IHibernateDao;

/**
 * @author laborc
 *
 */
public class SetSingleTime implements ISingleTime {

	public String modify(TimePoint timePoint) {
		return null;
	}
	public boolean alreadSet() {
		return false;
	}
	public List<Object> showTimeClass() {
		return null;
	}
	public List<Object> showTimePoint() {
		return null;
	}

	public TeacherTimePoint showTimePoint(Topics topics, int timePointClassNum) {
		String hql = "from TeacherTimePoint ttp where ttp.topicsNum="+topics.getTopicsNum()+" and ttp.timePointClass.TimePointClassNum="+timePointClassNum+" and ttp.canDo='0'";
		IHibernateDao dao = HibernateDaoFactory.createDao("timePointDao");
		List<Object> list = dao.selectByHql(hql);
		if(list.isEmpty())
		{
			return null;
		}else{
			TeacherTimePoint ttp = (TeacherTimePoint)list.get(0);
			return ttp;
		}
	}



	public String set(List<Topics> topicss,List<TeacherTimePoint> teacherTimePoint) {
		int i=0;
		IAdminOperateFactory factory = new SetTimeFactory();
		IMultiTime setTime = (IMultiTime)factory.create("mult");
		List<Object> list = setTime.showTimePoint();
		SchoolTimePoint stp = (SchoolTimePoint)list.get(0);
		String schoolYear = stp.getSchoolYear();
		String quarter = stp.getQuarter();
		for(Topics topics: topicss)
		{
			TeacherTimePoint ttp = teacherTimePoint.get(i);
			ttp.setTopicsNum(topics.getTopicsNum());
			ttp.setSchoolYear(schoolYear);
			ttp.setQuarter(quarter);
			i++;
		}
		IHibernateDao dao = HibernateDaoFactory.createDao("timePointDao");
		String result = dao.save(teacherTimePoint);
		return result;
	}
	public List<Object> showOneTime(int timeClassNum) {
		// TODO Auto-generated method stub
		return null;
	}
}
